package com.yxt.ui;

import java.io.File;

import com.yxt.common.sys.CommConstant;
import com.yxt.common.ui.ActivityStackControlUtil;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;  
import android.view.View.OnClickListener;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.TextView;
/**
 * 知识库详细
 * @author TYP
 *
 */
public class KnowledgeDetailActivity extends Activity {
	
	private void initComponent(){
		WebView webKnowledge = (WebView)findViewById(R.id.webKnowledge);
		Button btnBackHome = (Button)findViewById(R.id.btnBackHome);
		TextView lblTitle = (TextView)findViewById(R.id.lblTitle);
		TextView lblHeader = (TextView)findViewById(R.id.lblHeader);
		
		btnBackHome.setOnClickListener(new OnClickListener(){
			public void onClick(View arg0) {
				Intent intent = new Intent();
				intent.setClass(getApplicationContext(), MainActivity.class);
				startActivity(intent);
			}
		});
		Intent intent = getIntent();
		String url = CommConstant.Config.DEFAULT_PHONE_DIR+CommConstant.Config.HTML_LOCATION+intent.getStringExtra("url");		
		File file = new File(url);
		if (file.exists()) {		
			webKnowledge.loadUrl("content://com.android.htmlfileprovider"+url); 
		} else {
			webKnowledge.loadUrl("file:///android_asset/404.html"); 				
		}
		lblHeader.setText(intent.getStringExtra("title"));
		lblTitle.setText(intent.getStringExtra("header"));
	}
	
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);//去掉标题栏
		setContentView(R.layout.knowledge_detail);   //软件activity的布局	
		ActivityStackControlUtil.add(this);
		initComponent();
	}
	
	protected void onDestroy() {
		super.onDestroy();
        ActivityStackControlUtil.remove(this);
	}
}